package com.uum.auth.api.fallback;

import com.alibaba.fastjson.JSONObject;
import com.uum.auth.api.LoginFeignClient;
import com.uum.common.core.result.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginFallbackClient implements FallbackFactory<LoginFeignClient> {
    /**
     * 返回自定义异常
     * @param cause
     * @return
     */
    @Override
    public LoginFeignClient create(Throwable cause) {
        Result result = JSONObject.parseObject(cause.getMessage(), Result.class);
        return parameters -> result;
    }
}
